package dd.control;


import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import dd.model.Event;
import dd.model.Model;
import dd.view.CreateForm;
import dd.view.addChoiceScreen;
import dd.view.addEdgeFrame;


import xml.Message;

public class modCreateResponseController {
	/**
	 * call when the moderator get a create response 
	 * save the event id in the response
	 * go to different screen for open and close mode
	 */
	CreateForm cf;
	 public modCreateResponseController(){
		 Model model = Model.getInstance();
		 cf = model.getCreateForm();
	 }
	
	public void process(Message response){
		Model model= Model.getInstance();
		Event e = model.getEvent();
		Node update = response.contents.getFirstChild();
		NamedNodeMap map = update.getAttributes();
		String eventid = map.getNamedItem("id").getNodeValue();
		e.setEventID(eventid);
		//if open mode 
		if(e.getMode().equals("open")){
			addChoiceScreen addchoiceScreen = new addChoiceScreen(e);
			//	addchoiceScreen.getLBlModeratorChoice().setVisible(false);
			addchoiceScreen.setVisible(true);
			model.getCreateForm().dispose();
		}
		//if close mode
		else {
			addEdgeFrame aes = new addEdgeFrame();
			aes.setVisible(true);
			model.getmac().dispose();
		}
		
	}
}
